package com.rftennis.service.impl;

import java.time.LocalDateTime;
import java.util.UUID;

import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.Trim;

import com.rftennis.ao.RftennisOrderAo;
import com.rftennis.dao.OrderDao;
import com.rftennis.dao.SqlSessionUtil;
import com.rftennis.entity.OrderEntity;
import com.rftennis.entity.OrderItemEntity;
import com.rftennis.service.RftennisOrderService;
import com.rftennis.service.Uuid;

public class RftennisOrderServiceImpl implements RftennisOrderService{

	@Override
	public void addRftennis(RftennisOrderAo ao) throws Exception {
		//1验证参数
		//2执行业务逻辑
		try (SqlSession ss = SqlSessionUtil.getSession();){
			OrderDao dao=ss.getMapper(OrderDao.class);
			OrderEntity e=new OrderEntity();
			e.setAddress(ao.getAddress());
			e.setClosedCargTime(ao.getClosedCargTime());
			e.setCreateTime(LocalDateTime.now());
			e.setPhoneNumber(ao.getConsigneeTelephone());
			e.setId(Uuid.getUUID());
			e.setOrdNo(Uuid.getUUID());
			e.setStatus("no");
			e.setPrice(ao.getPrice());
			e.setCustomerId(ao.getCustomerId());
			e.setAddress(ao.getAddress());
			dao.insert(e);
			OrderItemEntity o=new OrderItemEntity();
			o.setId(Uuid.getUUID());
			o.setProductId(ao.getProductId());
			o.setProductPropertyId(ao.getProductPropertyId());
			o.setPrice(ao.getPrice1());
			o.setAmount(ao.getAmount());
			OrderEntity e1=new OrderEntity();
			e1.setId(e.getId());
			o.setOrderId(e1);
			ss.commit();
			ss.close();
		}
	//3组装结果
	}

	@Override
	public void deleteRftennis(RftennisOrderAo ao) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateRftennis(RftennisOrderAo ao) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void selectRftennis(RftennisOrderAo ao) throws Exception {
		// TODO Auto-generated method stub
		
	}
	

}
